package com.hibernate;

import java.sql.Timestamp;
import java.util.List;
import java.util.Set;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 	* A data access object (DAO) providing persistence and search support for Operation entities.
 			* Transaction control of the save(), update() and delete() operations 
		can directly support Spring container-managed transactions or they can be augmented	to handle user-managed Spring transactions. 
		Each of these methods provides additional information for how to configure it for the desired type of transaction control. 	
	 * @see com.hibernate.Operation
  * @author MyEclipse Persistence Tools 
 */

public class OperationDAO extends BaseHibernateDAO  {
	     private static final Logger log = LoggerFactory.getLogger(OperationDAO.class);
		//property constants
	public static final String MONTANTOPERATION = "montantoperation";
	public static final String CHAMP39OPERATION = "champ39operation";
	public static final String CHAMP2OPERATION = "champ2operation";
	public static final String CHAMP4OPERATTION = "champ4operattion";
	public static final String CHAMP3OPERATION = "champ3operation";
	public static final String CHAMP12OPERATION = "champ12operation";
	public static final String CHAMP18OPERATION = "champ18operation";
	public static final String CHAMP26OPERATION = "champ26operation";
	public static final String CHAMP32OPERATION = "champ32operation";
	public static final String CHAMP49OPERATION = "champ49operation";
	public static final String CHAMP52OPERATION = "champ52operation";
	public static final String CHAMP100OPERATION = "champ100operation";
	public static final String TYPEOPERATION = "typeoperation";



    
    public void save(Operation transientInstance) {
        log.debug("saving Operation instance");
        try {
            getSession().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }
    
	public void delete(Operation persistentInstance) {
        log.debug("deleting Operation instance");
        try {
            getSession().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
    
    public Operation findById( java.lang.Integer id) {
        log.debug("getting Operation instance with id: " + id);
        try {
            Operation instance = (Operation) getSession()
                    .get("com.hibernate.Operation", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
    
    
    public List findByExample(Operation instance) {
        log.debug("finding Operation instance by example");
        try {
            List results = getSession()
                    .createCriteria("com.hibernate.Operation")
                    .add(Example.create(instance))
            .list();
            log.debug("find by example successful, result size: " + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }    
    
    public List findByProperty(String propertyName, Object value) {
      log.debug("finding Operation instance with property: " + propertyName
            + ", value: " + value);
      try {
         String queryString = "from Operation as model where model." 
         						+ propertyName + "= ?";
         Query queryObject = getSession().createQuery(queryString);
		 queryObject.setParameter(0, value);
		 return queryObject.list();
      } catch (RuntimeException re) {
         log.error("find by property name failed", re);
         throw re;
      }
	}

	public List findByMontantoperation(Object montantoperation
	) {
		return findByProperty(MONTANTOPERATION, montantoperation
		);
	}
	
	public List findByChamp39operation(Object champ39operation
	) {
		return findByProperty(CHAMP39OPERATION, champ39operation
		);
	}
	
	public List findByChamp2operation(Object champ2operation
	) {
		return findByProperty(CHAMP2OPERATION, champ2operation
		);
	}
	
	public List findByChamp4operattion(Object champ4operattion
	) {
		return findByProperty(CHAMP4OPERATTION, champ4operattion
		);
	}
	
	public List findByChamp3operation(Object champ3operation
	) {
		return findByProperty(CHAMP3OPERATION, champ3operation
		);
	}
	
	public List findByChamp12operation(Object champ12operation
	) {
		return findByProperty(CHAMP12OPERATION, champ12operation
		);
	}
	
	public List findByChamp18operation(Object champ18operation
	) {
		return findByProperty(CHAMP18OPERATION, champ18operation
		);
	}
	
	public List findByChamp26operation(Object champ26operation
	) {
		return findByProperty(CHAMP26OPERATION, champ26operation
		);
	}
	
	public List findByChamp32operation(Object champ32operation
	) {
		return findByProperty(CHAMP32OPERATION, champ32operation
		);
	}
	
	public List findByChamp49operation(Object champ49operation
	) {
		return findByProperty(CHAMP49OPERATION, champ49operation
		);
	}
	
	public List findByChamp52operation(Object champ52operation
	) {
		return findByProperty(CHAMP52OPERATION, champ52operation
		);
	}
	
	public List findByChamp100operation(Object champ100operation
	) {
		return findByProperty(CHAMP100OPERATION, champ100operation
		);
	}
	
	public List findByTypeoperation(Object typeoperation
	) {
		return findByProperty(TYPEOPERATION, typeoperation
		);
	}
	

	public List findAll() {
		log.debug("finding all Operation instances");
		try {
			String queryString = "from Operation";
	         Query queryObject = getSession().createQuery(queryString);
			 return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
    public Operation merge(Operation detachedInstance) {
        log.debug("merging Operation instance");
        try {
            Operation result = (Operation) getSession()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(Operation instance) {
        log.debug("attaching dirty Operation instance");
        try {
            getSession().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    public void attachClean(Operation instance) {
        log.debug("attaching clean Operation instance");
        try {
            getSession().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
}